﻿using Newtonsoft.Json;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace FieldTools.Client.Entity.OneBot
{
    /// <summary>
    /// OneBot消息事件
    /// </summary>
    public class OneBotEnevtMessageInfo : OneBotEventBaseInfo
    {
        /// <summary>
        /// 消息类型,private
        /// </summary>
        [JsonProperty("message_type")]
        public string? MessageType { get; set; }
        /// <summary>
        /// 消息子类型，如果是好友则是 friend，如果是群临时会话则是 group，否者是other
        /// </summary>
        [JsonProperty("sub_type")]
        public string? SubType { get; set; }
        /// <summary>
        /// 消息id
        /// </summary>
        [JsonProperty("message_id")]
        public long? MessageId { get; set; }
        /// <summary>
        /// 发送请求的 QQ 号
        /// </summary>
        [JsonProperty("user_id")]
        public long? UserId { get; set; }
        /// <summary>
        /// 消息内容
        /// </summary>
        [JsonProperty("message")]
        public object? Message { get; set; }
        /// <summary>
        /// 原始消息内容
        /// </summary>
        [JsonProperty("raw_message")]
        public string? RawMessage { get; set; }
        /// <summary>
        /// 字体
        /// </summary>
        [JsonProperty("font")]
        public long? Font { get; set; }
        /// <summary>
        /// 发送人信息
        /// </summary>
        [JsonProperty("sender")]
        public Sender? Sender { get; set; }

        /// <summary>
        /// group独有。收到事件的群号
        /// </summary>
        [JsonProperty("group_id")]
        public long? GroupId { get; set; }
        /// <summary>
        /// group独有。匿名信息，如果不是匿名消息则为 null
        /// </summary>
        [JsonProperty("anonymous")]
        public Anonymous? Anonymous { get; set; }
    }

    /// <summary>
    /// 转码后的消息
    /// </summary>
    public class Message
    {
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("data")]
        public object? Data { get; set; }
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("type")]
        public string? Type { get; set; }
    }

    /// <summary>
    /// 匿名信息，如果不是匿名消息则为 null
    /// </summary>
    public class Anonymous
    {
        /// <summary>
        /// 匿名用户 ID
        /// </summary>
        [JsonProperty("id")]
        public long Id { get; set; }
        /// <summary>
        /// 匿名用户名称
        /// </summary>
        [JsonProperty("name")]
        public string Name { get; set; }
        /// <summary>
        /// 匿名用户 flag，在调用禁言 API 时需要传入
        /// </summary>
        [JsonProperty("flag")]
        public string Flag { get; set; }
    }

    /// <summary>
    /// 发送者信息
    /// </summary>
    public class Sender
    {
        /// <summary>
        /// 发送者 QQ 号
        /// </summary>
        [JsonProperty("user_id")]
        public long UserId { get; set; }
        /// <summary>
        /// 昵称
        /// </summary>
        [JsonProperty("nickname")]
        public string Nickname { get; set; }
        /// <summary>
        /// 性别，male 或 female 或 unknown
        /// </summary>
        [JsonProperty("sex")]
        public string Sex { get; set; }
        /// <summary>
        /// 年龄
        /// </summary>
        [JsonProperty("age")]
        public int Age { get; set; }

        /// <summary>
        /// group独有。群名片／备注
        /// </summary>
        [JsonProperty("card")]
        public string Card { get; set; }
        /// <summary>
        /// group独有。地区
        /// </summary>
        [JsonProperty("area")]
        public string Area { get; set; }
        /// <summary>
        /// group独有。成员等级
        /// </summary>
        [JsonProperty("level")]
        public string Level { get; set; }
        /// <summary>
        /// group独有。角色，owner 或 admin 或 member
        /// </summary>
        [JsonProperty("role")]
        public string Role { get; set; }
        /// <summary>
        /// group独有。专属头衔
        /// </summary>
        [JsonProperty("title")]
        public string Title { get; set; }
    }
    /// <summary>
    /// 消息事件的快速操作回复
    /// </summary>
    public class QuickHandleMessageInfo
    {
        /// <summary>
        /// 要回复的内容。默认不回复
        /// </summary>
        [JsonProperty("reply")]
        public object? Reply { get; set; } = null;
        /// <summary>
        /// 消息内容是否作为纯文本发送（即不解析 CQ 码），只在 reply 字段是字符串时有效。默认不转义
        /// </summary>
        [JsonProperty("auto_escape")]
        public bool AutoEscape { get; set; } = false;
        /// <summary>
        /// group独有。是否要在回复开头 at 发送者（自动添加），发送者是匿名用户时无效。默认at 发送者
        /// </summary>
        [JsonProperty("at_sender")]
        public bool AtSender { get; set; } = true;
        /// <summary>
        /// group独有。是否撤回该条消息。默认不撤回
        /// </summary>
        [JsonProperty("delete")]
        public bool Delete { get; set; } = false;
        /// <summary>
        /// group独有。是否把发送者踢出群组（需要登录号权限足够），不拒绝此人后续加群请求，发送者是匿名用户时无效。默认不踢
        /// </summary>
        [JsonProperty("kick")]
        public bool Kick { get; set; } = false;
        /// <summary>
        /// group独有。是否把发送者禁言 ban_duration 指定时长，对匿名用户也有效。默认不禁言
        /// </summary>
        [JsonProperty("ban")]
        public bool Ban { get; set; } = false;
        /// <summary>
        /// group独有。禁言时长。默认30分钟
        /// </summary>
        [JsonProperty("ban_duration")]
        public int BanDuration { get; set; } = 30;
    }
}
